/* 自定义菜单栏 */
/*$(function () {
  var ele = $('.header02 .custommenulist a');
  var i, j, k;

  panduan();
  $(window).resize(panduan);
  header02hover(i, j);

  function panduan() {
    i = -1;
    j = -1;
    ele.each(function (index) {
      if ($(this).offset().top > 50) {
        i = index;
        return false;
      }
    });

    ele.each(function (index) {
      if ($(this).offset().top > 100 && $(this).offset().top < 150) {
        j = index;
        return false;
      }
    });

    header02hover(i, j);
  }

  function header02hover(i, j) {
    //console.log(i,j);
    $('.custommenulist').hover(function () {
      if (j > 1) {
        $('.header02').height(90);
        $('.header02 .custommenulist').height(90);
      } else {
        if (i > 1) {
          $('.header02').height(60);
          $('.header02 .custommenulist').height(60);
        } else {}
      }
    }, function () {
      $('.header02').height(30);
      $('.header02 .custommenulist').height(30);
    });
  }

});*/

/* 历史访问记录 */
/*$(function () {
  var eles = $('.historylink .link-menu');
  var menu = eles.find('.menu-list');
  eles.click(function () {
    menu.css({
      'height': 'auto',
      'padding': '10px 0',
      'opacity': 1
    });
  });
  eles.mouseleave(function () {
    menu.css({
      'height': 0,
      'padding': 0,
      'opacity': 0
    });
  });
});*/

/* 左侧导航动画 */
$(function () {
  var leftbars = $('.leftnav .navitem a');
  var leftbars2 = $('.leftnav .navitem');

  /*leftbars.click(function () {
    leftbars.find('.iconlink').removeClass('active');
    $(this).find('.iconlink').addClass('active');
  });*/
  /*leftbars.click(function () {
    leftbars.removeClass('active');
    $(this).addClass('active');
  });*/

  leftbars2.hover(function () {
    //$(this).find('.subnav').css('display', 'flex');
    $(this).find('.subnav').fadeIn(300);
  }, function () {
    $(this).find('.subnav').css('display', 'none');
  });
});

/* 右上导航内容生成 */
$(function () {
  var targets = $('.navitem .active').next('.subnav');
  var targetNormal = $('.navitem .iconlink').next('.subnav');
  var elesNormalLink = targetNormal.find('.subnav-list');
  var eles = targets.find('.subnav-list');
  var title;


  var id = window.location.href;
  id = id.split('?');
  id = id[1];

  if (id) {
    title = eles.find('.subnavlink').eq(id).text();
  } else {
    title = eles.find('.subnavlink').eq(0).text();
  }

  $('.title span').text(title);
  $('.menu .menulist').text(title);
  

  $('.navitem .active .subnav').click(function(){
    var eles = $(this).find('.subnav-list');
    eles.clone(true).appendTo('.menu');
    
    return false;
  });
  
});

/* 右上导航动画 */


/* back to top button */
$(function () {
  var backButton = $('#backtotop');
  backButton.click(backToTop);

  $(window).scroll(function () {
    if ($(window).scrollTop() > 300) { //
      backButton.fadeIn(500);
    } else {
      backButton.hide();
    }
  });
  $(window).trigger('scroll');

  function backToTop() {
    $('html,body').animate({
      scrollTop: 0
    }, 300);
  }
});
